﻿using Shop.Collect;
using Shop.RemoteModel;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;

namespace Shop.LocalEvent.Activity
{
    [LocalEventName("Delete")]
    internal class ClearActivityEvent : IEventHandler<ActivityEvent>
    {
        private readonly IActivityDiscountCollect _Discount;
        private readonly IActivityGoodsCollect _Goods;

        public ClearActivityEvent (IActivityDiscountCollect discount, IActivityGoodsCollect goods)
        {
            this._Discount = discount;
            this._Goods = goods;
        }

        public void HandleEvent (ActivityEvent data, string eventName)
        {
            this._Discount.Clear(data.Activity.Id);
            if (data.Activity.ActivityType == ActivityType.店铺促销 && data.Activity.Range == DiscountRangeType.全场)
            {
                return;
            }
            this._Goods.Clear(data.Activity.Id);
        }
    }
}
